Load packages

library(tidyverse) # for data wrangling, ggplots
## ── Attaching packages ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────── tidyverse 1.3.0 ──
## ✓ ggplot2 3.3.3     ✓ purrr   0.3.3
## ✓ tibble  3.1.0     ✓ dplyr   1.0.5
## ✓ tidyr   1.0.0     ✓ stringr 1.4.0
## ✓ readr   1.3.1     ✓ forcats 0.4.0
## ── Conflicts ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── tidyverse_conflicts() ──
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()
library(cowplot) # for combining/modifying ggplots
library(networkD3) # for interactive Sankey plots
library(ggsci) # for color palettes
library(plotly) # for making interactive plots
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout
library(UpSetR) # for making sunburst plots
library(orca) # for saving static plots from plotly

Load literature review data sheet

lit0 <- read.csv("LitReview.xlsx - primarLit.csv")
nrow(lit0)
## [1] 365

Get rid of non quantitative gene expression methods

levels(as.factor(lit0$Method))
##  [1] "Expressed sequence tags"  "in situ hybridization"   
##  [3] "microarray"               "Northern blot"           
##  [5] "protein immunoblotting"   "qRT-PCR"                 
##  [7] "reannealing rate assay"   "shotgun RNAseq"          
##  [9] "shotgun RNAseq;qRT-PCR"   "single cell RNAseq"      
## [11] "SSH"                      "tag-based RNAseq"        
## [13] "tag-based RNAseq;qRT-PCR"
lit0 <- lit0 %>% filter(!Method %in% c("Expressed sequence tags", "protein immunoblotting", 
                                     "reannealing rate assay", "Northern blot", "in situ hybridization"))
levels(as.factor(lit0$Method))
##  [1] "Expressed sequence tags"  "in situ hybridization"   
##  [3] "microarray"               "Northern blot"           
##  [5] "protein immunoblotting"   "qRT-PCR"                 
##  [7] "reannealing rate assay"   "shotgun RNAseq"          
##  [9] "shotgun RNAseq;qRT-PCR"   "single cell RNAseq"      
## [11] "SSH"                      "tag-based RNAseq"        
## [13] "tag-based RNAseq;qRT-PCR"

How many publications now?

nrow(lit0)
## [1] 350

Tally the number of experimental factors to distinguish between single- and multiple-stressor studies

lit0  %>% filter(NumStressInt == 1) %>% summarize(n = n(),
                                                 prop = n()/nrow(lit0))
##     n      prop
## 1 195 0.5571429

Number of multiple stressor studies

lit0 %>% filter(NumStressInt > 1) %>% summarize(n = n(),
                                                 prop = n()/nrow(lit0))
##    n      prop
## 1 46 0.1314286

Histogram of number of stressors

lit0 %>%
  ggplot(aes(x = NumStressInt)) +
  geom_histogram(binwidth = 1, color="white") +
  xlab("Number of Stressors Examined")+
  ylab("Number of Publications")+
  theme_classic()
## Warning: Removed 109 rows containing non-finite values (stat_bin).

What percentage of studies include an interaction between multiple simultaneous stressors?

lit0 %>% filter(!is.na(Expt.Factors.Stress)) %>% tally()
##     n
## 1 241
lit0 %>% filter(!is.na(Expt.Factors.Stress)) %>% filter(Interaction=="interaction") %>% tally()
##    n
## 1 23

What factors do those studies that include an interaction consider?

lit0 %>% filter(Interaction=="interaction") %>% select(Expt.Factors.Stress)
##                            Expt.Factors.Stress
## 1                   temperature;UVR;temp x UVR
## 2          temperature;acidification;temp x OA
## 3  pathogen;temperature;pathogen x temperature
## 4                             pollutants x UVR
## 5              pollutants;UVR;pollutants x UVR
## 6                                    temp x OA
## 7          temperature;acidification;temp x OA
## 8         temperature;sediment;temp x sediment
## 9                   temperature;UVR;temp x UVR
## 10         temperature;acidification;temp x OA
## 11            temperature;injury;temp x injury
## 12                      pathogen x temperature
## 13          temperature;pathogen x temperature
## 14    temperature;pollutants;temp x pollutants
## 15                      pathogen x temperature
## 16         temperature;acidification;temp x OA
## 17         temperature;acidification;temp x OA
## 18         temperature;acidification;temp x OA
## 19 temperature;pathogen;pathogen x temperature
## 20        temperature;salinity;temp x salinity
## 21        temperature;sediment;temp x sediment
## 22                  temperature;UVR;temp x UVR
## 23       temperature;nutrients;temp x nutrient

What proportion of metagenomic?

lit0 %>% select(Scope) %>% group_by(Scope) %>% summarize(n())
## # A tibble: 2 x 2
##   Scope               `n()`
##   <fct>               <int>
## 1 metatranscriptomics    59
## 2 single organism       291

Format literature spreadsheet to save as a supplemental table

# write.csv(lit0, file = "TableS1.csv", row.names = F)

Format literature spreadsheet for analysis

Keep columns containing title (TI), Journal (SO), Scope, Method, DevelopmentalStage, Study.Focus, Expt.Factors, Expt.Factors.Stress, NumStressInt, Conservation.Relevance, Partner, FocalSpp, Focal.Fam, and year (PY)

lit1 <- lit0 %>% select(Scope, Method, DevelopmentalStage, Study.Focus, Expt.Factors, Expt.Factors.Stress, NumStressInt, 
                       Conservation.Relevance, Partner, FocalSpp, Focal.Fam,
                       PY, TI, SO)

How many total citations?

nrow(lit1)
## [1] 350

Make new rows for each entry within the lit review terms

lit1 <- lit1 %>% separate_rows(Method, sep = ";") %>% separate_rows(Study.Focus, sep = ";") %>%
  separate_rows(Expt.Factors, sep = ";") %>% separate_rows(Conservation.Relevance, sep = ";") %>%
  separate_rows(DevelopmentalStage, sep = ";")

Make new rows for each entry for a particular species. Match the species to the family

lit1 <- lit1 %>% separate_rows(FocalSpp, sep = ";")
# write.csv(file="species.csv",levels(as.factor(lit$FocalSpp)))
# I manually added family taxa to the species we have here
spp2fam <- read.csv("species.csv")
spp2fam
##                         species           family
## 1                      Acropora      Acroporidae
## 2              Acropora aculeus      Acroporidae
## 3               Acropora aspera      Acroporidae
## 4              Acropora austera      Acroporidae
## 5             Acropora cerealis      Acroporidae
## 6          Acropora cervicornis      Acroporidae
## 7           Acropora digitifera      Acroporidae
## 8            Acropora eurystoma      Acroporidae
## 9              Acropora formosa      Acroporidae
## 10           Acropora gemmifera      Acroporidae
## 11          Acropora hyacinthus      Acroporidae
## 12          Acropora intermedia      Acroporidae
## 13             Acropora loripes      Acroporidae
## 14       Acropora microphthalma      Acroporidae
## 15           Acropora millepora      Acroporidae
## 16            Acropora muricata      Acroporidae
## 17                Acropora nana      Acroporidae
## 18              Acropora nasuta      Acroporidae
## 19             Acropora palmata      Acroporidae
## 20            Acropora pruinosa      Acroporidae
## 21             Acropora pulchra      Acroporidae
## 22              Acropora selago      Acroporidae
## 23              Acropora tenuis      Acroporidae
## 24                     Aiptasia      Aiptasiidae
## 25             Aiptasia pallida      Aiptasiidae
## 26             Anemonia viridis       Actiniidae
## 27      Anomastraea irregularis   Coscinaraeidae
## 28    Anthopleura elegantissima       Actiniidae
## 29        Astroides calycularis Dendrophylliidae
## 30                     Bacteria         Bacteria
## 31        Balanophyllia elegans Dendrophylliidae
## 32       Balanophyllia europaea Dendrophylliidae
## 33                    Breviolum  Symbiodiniaceae
## 34            Breviolum minutum  Symbiodiniaceae
## 35            Callogorgia delta       Primnoidae
## 36           Capnella imbricata       Primnoidae
## 37        Caryophyllia inornata  Caryophylliidae
## 38                  Cladocopium  Symbiodiniaceae
## 39          Cladocopium goreaui  Symbiodiniaceae
## 40         Cladocora caespitosa         Faviidae
## 41             Corallium rubrum      Coralliidae
## 42        Corynactis californic Corallimorphidae
## 43           Ctenactis echinata        Fungiidae
## 44            Dendrophyllia sp. Dendrophylliidae
## 45        Desmophyllum dianthus  Caryophylliidae
## 46                  Durusdinium  Symbiodiniaceae
## 47                    Effrenium  Symbiodiniaceae
## 48        Eguchipsammia fistula Dendrophylliidae
## 49           Eunicea calyculata      Plexauridae
## 50             Euphyllia ancora     Euphylliidae
## 51        Euphyllia glabrescens     Euphylliidae
## 52         Euphyllia paradivisa     Euphylliidae
## 53                 Favia fragum         Faviidae
## 54             Favites colemani      Merulinidae
## 55                     Fugacium  Symbiodiniaceae
## 56          Fugacium kawagutii   Symbiodiniaceae
## 57              Fungia scutaria        Fungiidae
## 58             Galaxea astreata     Euphylliidae
## 59         Galaxea fascicularis     Euphylliidae
## 60                  Gerakladium  Symbiodiniaceae
## 61           Gorgonia ventalina      Gorgoniidae
## 62           Heliopora coerulea     Helioporidae
## 63        Leiopathes glaberrima     Leiopathidae
## 64         Leptopsammia pruvoti Dendrophylliidae
## 65             Lophelia pertusa  Caryophylliidae
## 66        Montastraea cavernosa   Montastraeidae
## 67   Montipora aequituberculata      Acroporidae
## 68           Montipora capitata      Acroporidae
## 69           Montipora digitata      Acroporidae
## 70            Montipora hispida      Acroporidae
## 71       Montipora monasteriata      Acroporidae
## 72          Orbicella faveolata      Merulinidae
## 73            Orbicella franksi      Merulinidae
## 74                   Ostreobium    Ostreobiaceae
## 75                 Paramuricea       Plexauridae
## 76          Paramuricea biscaya      Plexauridae
## 77             Pavona decussata      Agariciidae
## 78            Platygyra carnosa      Merulinidae
## 79           Platygyra daedalea      Merulinidae
## 80         Pleuractis granulosa        Fungiidae
## 81            Pocillopora acuta   Pocilloporidae
## 82     Pocillopora cf. capitata   Pocilloporidae
## 83       Pocillopora damicornis   Pocilloporidae
## 84              Pocillopora spp   Pocilloporidae
## 85        Pocillopora verrucosa   Pocilloporidae
## 86           Porites astreoides        Poritidae
## 87           Porites cylindrica        Poritidae
## 88            Porites harrisoni        Poritidae
## 89               Porites lobata        Poritidae
## 90                   Porites sp        Poritidae
## 91      Pseudodiploria strigosa         Mussidae
## 92           Rhizotrochus typus      Flabellidae
## 93                Ricordea yuma      Ricordeidae
## 94   Scleronephthya gracillimum      Nephtheidae
## 95       Seriatopora caliendrum   Pocilloporidae
## 96          Seriatopora hystrix   Pocilloporidae
## 97          Siderastrea siderea   Siderastreidae
## 98           Sinularia cruciata      Alcyoniidae
## 99       Staphylococcus hominis         Bacteria
## 100       Stylophora pistillata   Pocilloporidae
## 101             Symbiodiniaceae  Symbiodiniaceae
## 102                Symbiodinium  Symbiodiniaceae
## 103               Symbiodinium   Symbiodiniaceae
## 104 Symbiodiniummicroadriaticum  Symbiodiniaceae
## 105         Symbiodiniumvoratum  Symbiodiniaceae
## 106       Turbinaria reniformis Dendrophylliidae
## 107      Vibrio coralliilyticus         Bacteria
## 108               Vibrio shiloi         Bacteria
## 109             Vibrio shilonii         Bacteria
levels(as.factor(spp2fam$family))
##  [1] "Acroporidae"      "Actiniidae"       "Agariciidae"      "Aiptasiidae"     
##  [5] "Alcyoniidae"      "Bacteria"         "Caryophylliidae"  "Coralliidae"     
##  [9] "Corallimorphidae" "Coscinaraeidae"   "Dendrophylliidae" "Euphylliidae"    
## [13] "Faviidae"         "Flabellidae"      "Fungiidae"        "Gorgoniidae"     
## [17] "Helioporidae"     "Leiopathidae"     "Merulinidae"      "Montastraeidae"  
## [21] "Mussidae"         "Nephtheidae"      "Ostreobiaceae"    "Plexauridae"     
## [25] "Pocilloporidae"   "Poritidae"        "Primnoidae"       "Ricordeidae"     
## [29] "Siderastreidae"   "Symbiodiniaceae"
# test it out...
test <- merge(lit1, spp2fam, by.x = "FocalSpp", by.y = "species", all.x=T) %>%
  select(TI, DevelopmentalStage, FocalSpp, Focal.Fam, family)
test %>% select(TI) %>% distinct() %>% tally()
##     n
## 1 350
lit <-  merge(lit1, spp2fam, by.x = "FocalSpp", by.y = "species", all.x=T)

How many studies now?

lit %>% select(TI) %>% distinct() %>% tally()
##     n
## 1 350

Make sure that every entry is named exactly the same (e.g., long term stress and long term stress (>31d) need to be renamed to be the same)

levels(lit$Scope)
## [1] "metatranscriptomics" "single organism"
levels(lit$DevelopmentalStage)
## NULL
levels(as.factor(lit$Method))
## [1] "microarray"         "qRT-PCR"            "shotgun RNAseq"    
## [4] "single cell RNAseq" "SSH"                "tag-based RNAseq"
levels(as.factor(lit$Study.Focus))
##  [1] "calcification"               "circadian rhythm"           
##  [3] "comparative transcriptomics" "competition"                
##  [5] "disease"                     "fluorescence"               
##  [7] "functional characterization" "intercolony variation"      
##  [9] "intracolony variation"       "life history"               
## [11] "long term stress"            "moderate term stress"       
## [13] "population comparison"       "reproduction"               
## [15] "short term stress"           "symbiosis"                  
## [17] "temporal variation"
levels(as.factor(lit$Expt.Factors))
##  [1] "acclimation"             "acidification"          
##  [3] "algal species"           "allorecognition"        
##  [5] "antibiotics"             "color morph"            
##  [7] "competitive interaction" "cryopreservation"       
##  [9] "depth"                   "developmental stage"    
## [11] "feeding"                 "field sites"            
## [13] "genotype"                "growth anomaly"         
## [15] "infection status"        "injury"                 
## [17] "life stage"              "light intensity"        
## [19] "light:dark"              "lunar cycle"            
## [21] "microplastic"            "mucus exposure"         
## [23] "nutrients"               "oxygen level"           
## [25] "pathogen"                "pathogen x temperature" 
## [27] "pharmacological"         "pollutants"             
## [29] "pollutants x UVR"        "reproductive cycle"     
## [31] "salinity"                "sediment"               
## [33] "settlement cue"          "source population"      
## [35] "species"                 "strain"                 
## [37] "symbiosis"               "symbiotic state"        
## [39] "temp x injury"           "temp x nutrient"        
## [41] "temp x OA"               "temp x pollutants"      
## [43] "temp x salinity"         "temp x sediment"        
## [45] "temp x UVR"              "temperature"            
## [47] "time course"             "tissue"                 
## [49] "trace metals"            "UVR"
levels(as.factor(lit$Conservation.Relevance))
## [1] "biomarker"                   "cryptic species"            
## [3] "heritability"                "inter-population variation" 
## [5] "intra-population variation"  "management decisions"       
## [7] "methods development"         "reef restoration technology"
## [9] "restoration lines"
levels(as.factor(lit$Partner))
##  [1] "Anemone host"                               
##  [2] "Anemone host;Symbiodiniaceae"               
##  [3] "Bacteria"                                   
##  [4] "Coral host"                                 
##  [5] "Coral host;other eukaryotes"                
##  [6] "Coral host;Symbiodiniaceae"                 
##  [7] "Coral host;Symbiodiniaceae;other eukaryotes"
##  [8] "Coral host;Symbiodinium"                    
##  [9] "Symbiodiniaceae"                            
## [10] "Symbiodiniaceae;virus"                      
## [11] "Symbiodinium"                               
## [12] "Symbiodinium microadriaticum"
levels(as.factor(lit$FocalSpp))
##   [1] "Acropora"                    "Acropora aculeus"           
##   [3] "Acropora aspera"             "Acropora austera"           
##   [5] "Acropora cerealis"           "Acropora cervicornis"       
##   [7] "Acropora digitifera"         "Acropora eurystoma"         
##   [9] "Acropora formosa"            "Acropora gemmifera"         
##  [11] "Acropora hyacinthus"         "Acropora intermedia"        
##  [13] "Acropora loripes"            "Acropora microphthalma"     
##  [15] "Acropora millepora"          "Acropora muricata"          
##  [17] "Acropora nana"               "Acropora nasuta"            
##  [19] "Acropora palmata"            "Acropora pruinosa"          
##  [21] "Acropora pulchra"            "Acropora selago"            
##  [23] "Acropora tenuis"             "Aiptasia"                   
##  [25] "Aiptasia pallida"            "Anemonia viridis"           
##  [27] "Anomastraea irregularis"     "Anthopleura elegantissima"  
##  [29] "Astroides calycularis"       "Bacteria"                   
##  [31] "Balanophyllia elegans"       "Balanophyllia europaea"     
##  [33] "Breviolum"                   "Breviolum minutum"          
##  [35] "Callogorgia delta"           "Capnella imbricata"         
##  [37] "Caryophyllia inornata"       "Cladocopium"                
##  [39] "Cladocopium goreaui"         "Cladocora caespitosa"       
##  [41] "Corallium rubrum"            "Corynactis californic"      
##  [43] "Ctenactis echinata"          "Dendrophyllia sp."          
##  [45] "Desmophyllum dianthus"       "Durusdinium"                
##  [47] "Effrenium"                   "Eguchipsammia fistula"      
##  [49] "Eunicea calyculata"          "Euphyllia ancora"           
##  [51] "Euphyllia glabrescens"       "Euphyllia paradivisa"       
##  [53] "Favia fragum"                "Favites colemani"           
##  [55] "Fugacium"                    "Fugacium kawagutii "        
##  [57] "Fungia scutaria"             "Galaxea astreata"           
##  [59] "Galaxea fascicularis"        "Gerakladium"                
##  [61] "Gorgonia ventalina"          "Heliopora coerulea"         
##  [63] "Leiopathes glaberrima"       "Leptopsammia pruvoti"       
##  [65] "Lophelia pertusa"            "Montastraea cavernosa"      
##  [67] "Montipora aequituberculata"  "Montipora capitata"         
##  [69] "Montipora digitata"          "Montipora hispida"          
##  [71] "Montipora monasteriata"      "Orbicella faveolata"        
##  [73] "Orbicella franksi"           "Ostreobium"                 
##  [75] "Paramuricea "                "Paramuricea biscaya"        
##  [77] "Pavona decussata"            "Platygyra carnosa"          
##  [79] "Platygyra daedalea"          "Pleuractis granulosa"       
##  [81] "Pocillopora acuta"           "Pocillopora cf. capitata"   
##  [83] "Pocillopora damicornis"      "Pocillopora spp"            
##  [85] "Pocillopora verrucosa"       "Porites astreoides"         
##  [87] "Porites cylindrica"          "Porites harrisoni"          
##  [89] "Porites lobata"              "Porites sp"                 
##  [91] "Pseudodiploria strigosa"     "Rhizotrochus typus"         
##  [93] "Ricordea yuma"               "Scleronephthya gracillimum" 
##  [95] "Seriatopora caliendrum"      "Seriatopora hystrix"        
##  [97] "Siderastrea siderea"         "Sinularia cruciata"         
##  [99] "Staphylococcus hominis"      "Stylophora pistillata"      
## [101] "Symbiodiniaceae"             "Symbiodinium"               
## [103] "Symbiodinium "               "Symbiodiniummicroadriaticum"
## [105] "Symbiodiniumvoratum"         "Turbinaria reniformis"      
## [107] "Vibrio coralliilyticus"      "Vibrio shiloi"              
## [109] "Vibrio shilonii"
levels(as.factor(lit$family))
##  [1] "Acroporidae"      "Actiniidae"       "Agariciidae"      "Aiptasiidae"     
##  [5] "Alcyoniidae"      "Bacteria"         "Caryophylliidae"  "Coralliidae"     
##  [9] "Corallimorphidae" "Coscinaraeidae"   "Dendrophylliidae" "Euphylliidae"    
## [13] "Faviidae"         "Flabellidae"      "Fungiidae"        "Gorgoniidae"     
## [17] "Helioporidae"     "Leiopathidae"     "Merulinidae"      "Montastraeidae"  
## [21] "Mussidae"         "Nephtheidae"      "Ostreobiaceae"    "Plexauridae"     
## [25] "Pocilloporidae"   "Poritidae"        "Primnoidae"       "Ricordeidae"     
## [29] "Siderastreidae"   "Symbiodiniaceae"

Combine all “Symbiodinium”-type partners

levels(as.factor(lit$Partner))
##  [1] "Anemone host"                               
##  [2] "Anemone host;Symbiodiniaceae"               
##  [3] "Bacteria"                                   
##  [4] "Coral host"                                 
##  [5] "Coral host;other eukaryotes"                
##  [6] "Coral host;Symbiodiniaceae"                 
##  [7] "Coral host;Symbiodiniaceae;other eukaryotes"
##  [8] "Coral host;Symbiodinium"                    
##  [9] "Symbiodiniaceae"                            
## [10] "Symbiodiniaceae;virus"                      
## [11] "Symbiodinium"                               
## [12] "Symbiodinium microadriaticum"
lit$Partner <- str_replace(lit$Partner, "Symbiodinium microadriaticum", "Symbiodiniaceae")
lit$Partner <- str_replace(lit$Partner, "Symbiodinium", "Symbiodiniaceae")

Save/Load: You can start here with the “lit” object

# save(lit, file="litSearch.RData")
load("litSearch.RData")

Method & Partner

Make a bar chart of study method

lit %>% group_by(Method) %>% filter(!is.na(Method)) %>% distinct(TI) %>% tally() %>%
 ggplot() +
  geom_bar(aes(reorder(Method,n),n), stat="identity", width=1, color="white") +
  theme_classic()+
  theme(axis.text.x = element_text(angle=45, vjust=1, hjust=1))+
  xlab("")+
  ylab("Number of Studies")

Plot method over time

colors <- pal_npg()(6)
lit %>% group_by(Method, PY) %>% filter(!is.na(Method)) %>% distinct(TI) %>% tally() %>%
  ggplot() +
  geom_line(aes(x=PY,y=n, group=Method,color=Method), size=1.5) +
  scale_color_manual(values=colors)+
  theme_classic()+
  theme(axis.text.x = element_text(angle=45, vjust=1, hjust=1))+
  xlab("")+
  ylab("Number of Studies")

colors <- pal_npg()(6)
lit %>% group_by(Method, PY) %>% filter(!is.na(Method)) %>% distinct(TI) %>% tally() %>%
  ggplot() +
  geom_bar(aes(x=PY,y=n, group=Method,fill=Method),position="stack", stat="identity") +
  theme_classic()+
  scale_fill_manual("Method",values=colors)+
    theme(axis.text.x = element_text(angle=45, vjust=1, hjust=1),
        legend.text=element_text(size=rel(0.75)),
        legend.title=element_text(size=rel(0.75)))+
  xlab("")+
  ylab("Number of Studies")

Remove SSH

colors <- pal_npg()(5)
plot.method.time <- lit %>% group_by(Method, PY) %>% 
  filter(!is.na(Method)) %>% filter(!Method=="SSH") %>% 
  distinct(TI) %>% tally() %>%
  ggplot() +
  geom_bar(aes(x=PY,y=n, group=Method,fill=Method),position="stack", stat="identity") +
  theme_classic()+
  scale_fill_manual("Method",values=colors)+
    theme(axis.text.x = element_text(angle=45, vjust=1, hjust=1),
        legend.text=element_text(size=rel(0.75)),
        legend.title=element_text(size=rel(0.75)))+
  xlab("")+
  ylab("Number of Studies")
plot.method.time

colors <- pal_npg()(9)
lit %>% group_by(Partner, PY) %>% filter(!is.na(Partner)) %>% distinct(TI) %>% tally() %>%
  ggplot() +
  geom_line(aes(x=PY,y=n, group=Partner,color=Partner), size=1.5) +
  theme_classic()+
  scale_color_manual(values=colors)+
    theme(axis.text.x = element_text(angle=45, vjust=1, hjust=1),
        legend.text=element_text(size=rel(0.75)),
        legend.title=element_text(size=rel(0.75)))+
  xlab("")+
  ylab("Number of Studies")

my_levels <- c("Coral host", 
                "Anemone host",
                "Coral host;Symbiodiniaceae", 
                "Coral host;Symbiodiniaceae;other eukaryotes",
                "Anemone host;Symbiodiniaceae",
                "Symbiodiniaceae",
                "Bacteria")

colors <- c("#E64B35FF", "#F39B7FFF", "#3C5488FF", "#8491B4FF",
            "#4DBBD5FF", "#00A087FF", "#91D1C2FF")

plot.partner.time <- lit %>% group_by(Partner) %>% filter(n()>5) %>% ungroup() %>%
  group_by(Partner, PY) %>% filter(!is.na(Partner)) %>% distinct(TI) %>% tally() %>%
  ggplot() +
  geom_bar(aes(x=PY,y=n, 
               group=factor(Partner,levels=my_levels),
               fill=factor(Partner,levels=my_levels)), 
           position="stack", stat="identity") +
  theme_classic()+
  scale_fill_manual(values=colors)+
  theme(axis.text.x = element_text(angle=45, vjust=1, hjust=1),
        legend.text=element_text(size=rel(0.75)),
        legend.title=element_text(size=rel(0.75)))+  
  xlab("")+
  ylab("Number of Studies")
plot.partner.time

Conservation Relevance

colors <- pal_npg()(10)
plot.conservation.time <- lit %>% group_by(Conservation.Relevance) %>% filter(n()>2) %>% ungroup() %>%
  group_by(Conservation.Relevance, PY) %>% filter(!is.na(Conservation.Relevance)) %>% distinct(TI) %>% tally() %>%
  ggplot() +
  geom_bar(aes(x=PY,y=n, group=Conservation.Relevance,
               fill=Conservation.Relevance), position="stack", stat="identity") +
  theme_classic()+
  scale_fill_manual("Conservation Relevance", values=colors)+
  theme(axis.text.x = element_text(angle=45, vjust=1, hjust=1),
        legend.text=element_text(size=rel(0.75)),
        legend.title=element_text(size=rel(0.75)))+
  xlab("")+
  ylab("Number of Studies")
plot.conservation.time

Remove “management decisions” (vague)

colors <- pal_npg()(10)
plot.conservation.time <- lit %>% filter(!Conservation.Relevance=="management decisions") %>%
  group_by(Conservation.Relevance) %>% filter(n()>2) %>% ungroup() %>%
  group_by(Conservation.Relevance, PY) %>% filter(!is.na(Conservation.Relevance)) %>% distinct(TI) %>% tally() %>%
  ggplot() +
  geom_bar(aes(x=PY,y=n, group=Conservation.Relevance,
               fill=Conservation.Relevance), position="stack", stat="identity") +
  theme_classic()+
  scale_fill_manual("Conservation Relevance", values=colors)+
  theme(axis.text.x = element_text(angle=45, vjust=1, hjust=1),
        legend.text=element_text(size=rel(0.75)),
        legend.title=element_text(size=rel(0.75)))+
  xlab("")+
  ylab("Number of Studies")
plot.conservation.time

Plot method, partner, and conservation relevance together

fig_stackedbarplot_method_parther_relevance <- plot_grid(
  plot_grid(
    plot.method.time + theme(legend.position = "none"), 
    plot.partner.time + theme(legend.position = "none"),
    plot.conservation.time + theme(legend.position = "none"), 
    ncol = 1, align = "hv", labels = "AUTO")
  , plot_grid(
    get_legend(plot.method.time), 
    get_legend(plot.partner.time),
    get_legend(plot.conservation.time), 
    ncol = 1, align = "hv"), 
  rel_widths = c(1,1,1)
  )
fig_stackedbarplot_method_parther_relevance

# ggsave(filename = "fig_stackedbarplot_method_partner_relevance.pdf",
       # plot = fig_stackedbarplot_method_parther_relevance,
       # width = 10, height = 10)

Study focus

Make a bar chart of the study focus

lit %>% group_by(Study.Focus) %>% distinct(TI) %>% tally() %>%
 ggplot() +
  geom_bar(aes(reorder(Study.Focus,n),n), stat="identity", width=1, color="white") +
  theme_classic()+
  theme(axis.text.x = element_text(angle=45, vjust=1, hjust=1))+
  xlab("")+
  ylab("Number of Studies")

Make a pie chart of the study focus

lit %>% group_by(Study.Focus) %>% distinct(TI) %>% tally() %>%
 ggplot(aes(x="", y=n, fill=Study.Focus)) +
  geom_bar(stat="identity", width=1, color="white") +
  coord_polar("y", start=0) +
  theme_void()

Experimental factors

Make a bar chart of the Experimental Factors

lit %>% group_by(Expt.Factors) %>% filter(!is.na(Expt.Factors)) %>% distinct(TI) %>% tally() %>%
 ggplot() +
  geom_bar(aes(reorder(Expt.Factors,n),n), stat="identity", width=1, color="white") +
  theme_classic()+
  theme(axis.text.x = element_text(angle=45, vjust=1, hjust=1))+
  xlab("")+
  ylab("Number of Studies")

lit %>% group_by(Expt.Factors) %>% filter(!is.na(Expt.Factors)) %>% distinct(TI) %>% tally() %>%
  filter(n>5) %>%
 ggplot() +
  geom_bar(aes(reorder(Expt.Factors,n),n), stat="identity", width=1, color="white") +
  theme_classic()+
  theme(axis.text.x = element_text(angle=45, vjust=1, hjust=1))+
  xlab("")+
  ylab("Number of Studies")

Focal families and species

Make a bar chart of the Focal Family

lit %>% group_by(Focal.Fam) %>% filter(!is.na(Focal.Fam)) %>% distinct(TI) %>% tally() %>%
 ggplot() +
  geom_bar(aes(reorder(Focal.Fam,n),n), stat="identity", width=1, color="white") +
  theme_classic()+
  theme(axis.text.x = element_text(angle=45, vjust=1, hjust=1))+
  xlab("")+
  ylab("Number of Studies")

lit %>% group_by(Focal.Fam) %>% filter(!is.na(Focal.Fam)) %>% distinct(TI) %>% tally() %>%
  filter(n>5) %>%
  ggplot() +
  geom_bar(aes(x=reorder(Focal.Fam,n),y=n), stat="identity", width=1, color="white") +
  theme_classic()+
  theme(axis.text.x = element_text(angle=45, vjust=1, hjust=1))+
  xlab("")+
  ylab("Number of Studies")

Sunburst plots

Figure 3A: The proportion of experiments by holobiont member, study focus, and experimental factors.

lit.sun.2 <- lit %>% select(Partner, Study.Focus, Expt.Factors, TI) %>% distinct()

How many experiments? How many publications?

nrow(lit.sun.2)
## [1] 748
lit.sun.2 %>% group_by(TI) %>% distinct(TI) %>% nrow()
## [1] 350

Make tallys and percentage by partner

lit.sun.2.partner <- lit.sun.2 %>% filter(!is.na(Partner)) %>% 
  group_by(Partner) %>% 
  tally() %>% arrange(desc(n)) %>%
  filter(n>7) %>%
  mutate(percent = round(n/sum(n),2)*100) %>%
  rename(ids = "Partner") %>%
  mutate(parents = "NA") %>%
  mutate(labels = paste0(ids, "<br>",percent,"%")) %>%
  select(ids, labels, parents, n, percent)

Make tallys and percentage by study focus for each partner

lit.sun.2.study <- lit.sun.2 %>% filter(!is.na(Partner)) %>%
  filter(Partner %in% lit.sun.2.partner$ids) %>%
  group_by(Partner, Study.Focus) %>% 
  tally() %>% arrange(desc(n)) %>%
  # filter(n>4) %>%
  mutate(percent = round(n/sum(n),2)*100) %>%
  rename(parents = "Partner") %>%
  mutate(ids = paste(Study.Focus,parents,sep="_")) %>%
  mutate(labels = paste0(Study.Focus,"<br>",percent,"%")) %>%
  select(ids, labels, parents, n, percent)

Make tallys and percentage by expt factor for each study focus for each partner

lit.sun.2.expt <- lit.sun.2 %>% filter(!is.na(Partner)) %>%
  group_by(Partner, Study.Focus, Expt.Factors) %>%
  filter(Partner %in% lit.sun.2.partner$ids) %>%
  tally() %>% arrange(desc(n)) %>%
  # filter(n>0) %>%
  mutate(percent = round(n/sum(n),2)*100) %>%
  mutate(parents = paste(Study.Focus,Partner,sep="_")) %>%
  mutate(ids = paste(Expt.Factors,parents,sep="_")) %>%
  mutate(labels = paste0(Expt.Factors,"<br>",percent,"%")) %>%
  select(ids, labels, parents, n, percent)
## Adding missing grouping variables: `Partner`, `Study.Focus`
sunplot.partner2study2expt.data <- bind_rows(lit.sun.2.partner,
                              lit.sun.2.study,
                              lit.sun.2.expt)

colors <- ifelse(grepl("^Coral host$", sunplot.partner2study2expt.data$ids),pal_npg()(1)[1],
                 ifelse(grepl("^Coral host;Sym", sunplot.partner2study2expt.data$ids),pal_npg()(4)[4],
                 ifelse(grepl("^Anemone host$", sunplot.partner2study2expt.data$ids),pal_npg()(5)[5],
                ifelse(grepl("^Anemone host;Sym", sunplot.partner2study2expt.data$ids),pal_npg()(2)[2],
                 ifelse(grepl("^Symbiodiniaceae", sunplot.partner2study2expt.data$ids),pal_npg()(3)[3],
                ifelse(grepl("_Symbiodiniaceae", sunplot.partner2study2expt.data$ids),pal_npg()(7)[7],
                ifelse(grepl("_Coral host$", sunplot.partner2study2expt.data$ids),pal_npg()(1)[1],
                ifelse(grepl("_Coral host;Sym", sunplot.partner2study2expt.data$ids),pal_npg()(4)[4],
                ifelse(grepl("_Anemone host$", sunplot.partner2study2expt.data$ids),pal_npg()(5)[5],
                ifelse(grepl("_Anemone host;Sym", sunplot.partner2study2expt.data$ids),pal_npg()(2)[2],
                ifelse(grepl("^Bacteria", sunplot.partner2study2expt.data$ids),pal_npg()(7)[7],
                ifelse(grepl("_Bacteria", sunplot.partner2study2expt.data$ids),pal_npg()(7)[7],
                 "grey"))))))))))))
sunplot.partner2study2expt.data$colors <- colors

Sunplot from study focus to expt factors

sunplot.partner2study2expt <- plot_ly(sunplot.partner2study2expt.data, ids = ~ids, labels = ~labels, 
                 parents = ~parents, values= ~n, 
                 type = 'sunburst', branchvalues = 'total',
                 insidetextorientation="auto",
                 width = 500, height = 400,
                 marker = list(colors = sunplot.partner2study2expt.data$colors),
                 color = I('#FFFFFF'))
sunplot.partner2study2expt
# orca(sunplot.partner2study2expt, file="sunplot_partner2study2expt.pdf")
# orca(sunplot.partner2study2expt, file="sunplot_partner2study2expt.svg")

Figure 3B: The proportion of experiments in coral hosts by life-stage, family, and species.

Make tallys and percentage by developmental stage

lit.sun.1 <- lit %>% filter(grepl("host",Partner)) %>%
  select(DevelopmentalStage, FocalSpp, family, TI) %>% distinct() %>% 
  filter(!is.na(DevelopmentalStage)) %>% filter(!DevelopmentalStage=="NA")

How many experiments? How many publications?

nrow(lit.sun.1)
## [1] 378
lit.sun.1 %>% group_by(TI) %>% distinct(TI) %>% nrow()
## [1] 298
lit.sun.1.dev.stage <- lit.sun.1 %>%
  group_by(DevelopmentalStage) %>%
  tally() %>% arrange(desc(n)) %>%
  mutate(percent = round(n/sum(n),2)*100) %>%
  rename(ids = "DevelopmentalStage") %>%
  mutate(parents = "NA") %>%
  mutate(labels = paste0(ids, "<br>",percent,"%")) %>%
  select(ids, labels, parents, n, percent)

Make tallys and percentage by focal family for each developmental stage

lit.sun.1.focal.fam <- lit.sun.1 %>% 
  filter(DevelopmentalStage %in% lit.sun.1.dev.stage$ids) %>%
  filter(!is.na(family)) %>%
  group_by(DevelopmentalStage, family) %>% 
  tally() %>% arrange(desc(n)) %>%
  mutate(percent = round(n/sum(n),2)*100) %>%
  rename(parents = "DevelopmentalStage") %>%
  mutate(ids = paste(family,parents,sep="_")) %>%
  mutate(labels = paste0(family,"<br>",percent,"%")) %>%
  select(ids, labels, parents, n, percent)
sunplot.dev2fam.data <- bind_rows(lit.sun.1.dev.stage,
                              lit.sun.1.focal.fam)

colors <- ifelse(grepl("^adult", sunplot.dev2fam.data$ids),pal_npg()(1)[1],
                 ifelse(grepl("^larvae", sunplot.dev2fam.data$ids),pal_npg()(4)[4],
                 ifelse(grepl("^juvenile", sunplot.dev2fam.data$ids),pal_npg()(2)[2],
                 ifelse(grepl("_adult", sunplot.dev2fam.data$ids),pal_npg()(5)[5],
                 ifelse(grepl("_larvae", sunplot.dev2fam.data$ids),pal_npg()(6)[6],
                 ifelse(grepl("_juvenile", sunplot.dev2fam.data$ids),pal_npg()(2)[2],
                 "grey"))))))

sunplot.dev2fam.data$colors <- colors
sunplot.dev2fam.data$colors <- if_else(grepl("Sym",sunplot.dev2fam.data$ids),
                                       true = pal_npg()(3)[3],
                                       false = sunplot.dev2fam.data$colors)

Sunplot from developmental stage to focal family

sunplot.dev2fam <- plot_ly(sunplot.dev2fam.data, ids = ~ids, labels = ~labels, 
                 parents = ~parents, values= ~n, 
                 type = 'sunburst', branchvalues = 'total',
                 insidetextorientation="auto",
                 marker = list(colors = sunplot.dev2fam.data$colors),
                 color = I('#FFFFFF'))
sunplot.dev2fam
# orca(sunplot.dev2fam, file="sunplot_dev2fam.pdf")
# orca(sunplot.dev2fam, file="sunplot_dev2fam.svg")

Developmental Stage –> Focal Family –> Focal Species

Make tallys and percentage by focal species for each focal family for each developmental stage

families <- sub("\\_.*", "", lit.sun.1.focal.fam$ids)

lit.sun.1.focal.spp <- lit.sun.1 %>% 
  filter(DevelopmentalStage %in% lit.sun.1.dev.stage$ids) %>% 
  filter(family %in% families) %>%
  group_by(DevelopmentalStage, family, FocalSpp) %>% 
  tally() %>% arrange(desc(n)) %>%
  # filter(n>5) %>%
  mutate(percent = round(n/sum(n),2)*100) %>%
  mutate(parents = paste(family,DevelopmentalStage,sep="_")) %>%
  mutate(ids = paste(FocalSpp,parents,DevelopmentalStage,sep="_")) %>%
  mutate(labels = paste0(FocalSpp,"<br>",percent,"%")) %>%
  select(ids, labels, parents, n, percent)
## Adding missing grouping variables: `DevelopmentalStage`, `family`
sunplot.dev2fam2spp.data <- bind_rows(lit.sun.1.dev.stage,
                              lit.sun.1.focal.fam,
                              lit.sun.1.focal.spp)

colors <- ifelse(grepl("^adult", sunplot.dev2fam2spp.data$ids),pal_npg()(1)[1],
                 ifelse(grepl("^larvae", sunplot.dev2fam2spp.data$ids),pal_npg()(4)[4],
                 ifelse(grepl("^juvenile", sunplot.dev2fam2spp.data$ids),pal_npg()(2)[2],
                 ifelse(grepl("_adult", sunplot.dev2fam2spp.data$ids),pal_npg()(5)[5],
                 ifelse(grepl("_larvae", sunplot.dev2fam2spp.data$ids),pal_npg()(6)[6],
                 ifelse(grepl("_juvenile", sunplot.dev2fam2spp.data$ids),pal_npg()(2)[2],
                 "grey"))))))

sunplot.dev2fam2spp.data$colors <- colors
sunplot.dev2fam2spp.data$colors <- if_else(grepl("Sym",sunplot.dev2fam2spp.data$ids),
                                       true = pal_npg()(3)[3],
                                       false = sunplot.dev2fam2spp.data$colors)

Total number in this chart

sunplot.dev2fam2spp.data %>% filter(parents=="NA") %>% summarize(sum(n))
## # A tibble: 1 x 1
##   `sum(n)`
##      <int>
## 1      378

Sunplot from developmental stage to focal family to species

sunplot.dev2fam2spp <- plot_ly(sunplot.dev2fam2spp.data, ids = ~ids, labels = ~labels, 
                 parents = ~parents, values= ~n, 
                 type = 'sunburst', branchvalues = 'total',
                 insidetextorientation="auto",
                 width = 500, height = 400,
                 marker = list(colors = sunplot.dev2fam2spp.data$colors),
                 color = I('#FFFFFF'))
sunplot.dev2fam2spp
# orca(sunplot.dev2fam2spp, file="sunplot_dev2fam2spp2.pdf")
# orca(sunplot.dev2fam2spp, file="sunplot_dev2fam2spp2.svg")

Figure 3C: Multistressors

lit.sun.6 <- lit %>%
  select(Expt.Factors.Stress, NumStressInt, TI) %>% distinct() %>%
  filter(!is.na(Expt.Factors.Stress)) %>%
  group_by(TI)

How many experiments? How many publications?

nrow(lit.sun.6)
## [1] 241
lit.sun.6 %>% group_by(TI) %>% distinct(TI) %>% nrow()
## [1] 241
lit.sun.6.num <- lit.sun.6 %>% filter(!is.na(NumStressInt)) %>%
  group_by(NumStressInt) %>% 
  tally() %>% arrange(desc(n)) %>%
  filter(n>0) %>%
  mutate(percent = round(n/sum(n),2)*100) %>%
  mutate(parents = "NA") %>%
  mutate(ids = paste(NumStressInt)) %>%
  mutate(labels = paste0(NumStressInt,"<br>",percent,"%")) %>%
  select(ids, labels, parents, n, percent)
lit.sun.6.expt.fact<- lit.sun.6 %>%
  filter(!is.na(Expt.Factors.Stress)) %>%
  ungroup() %>%
  group_by(NumStressInt,Expt.Factors.Stress) %>% 
  tally() %>% arrange(desc(n)) %>%
  filter(n>0) %>%
  mutate(percent = round(n/sum(n),2)*100) %>%
  mutate(parents = paste(NumStressInt)) %>%
  mutate(ids = paste(Expt.Factors.Stress,parents,sep="_")) %>%
  mutate(labels = paste0(Expt.Factors.Stress,"<br>",percent,"%")) %>%
  select(ids, labels, parents, n, percent)
## Adding missing grouping variables: `NumStressInt`
sunplot.expt2num.data <- bind_rows(lit.sun.6.expt.fact,
                                lit.sun.6.num)

colors <- ifelse(grepl("1", sunplot.expt2num.data$ids),pal_npg()(1)[1],
                 ifelse(grepl("2", sunplot.expt2num.data$ids),pal_npg()(4)[4],
                 ifelse(grepl("3", sunplot.expt2num.data$ids),pal_npg()(3)[3],
                 ifelse(grepl("4", sunplot.expt2num.data$ids),pal_npg()(2)[2],
                 "grey"))))

sunplot.expt2num.data$colors <- colors

Sunplot from experimental factors to number of experimental factors

sunplot.num2exp <- plot_ly(sunplot.expt2num.data, ids = ~ids, labels = ~labels, 
                 parents = ~parents, values= ~n, 
                 type = 'sunburst', branchvalues = 'total',
                 insidetextorientation="auto",
                 width = 500, height = 400,
                 marker = list(colors = sunplot.expt2num.data$colors),
                 color = I('#FFFFFF'))
sunplot.num2exp
# orca(sunplot.num2exp, file = "sunplot_num2exp_sub.pdf")
# orca(sunplot.num2exp, file = "sunplot_num2exp_sub.svg")

Figure 3D: The empirical focus of studies with conservation and restoration relevance

lit.sun.4 <- lit %>% select(Expt.Factors, Conservation.Relevance, TI) %>% filter(!is.na(Conservation.Relevance)) %>% distinct()

How many experiments? How many publications?

nrow(lit.sun.4)
## [1] 181
lit.sun.4 %>% group_by(TI) %>% distinct(TI) %>% nrow()
## [1] 94
94/350
## [1] 0.2685714

Make tallys and percentage by conservation relevance

lit.sun.4.cons <- lit.sun.4 %>% filter(!is.na(Conservation.Relevance)) %>%
  group_by(Conservation.Relevance) %>% 
  tally() %>% arrange(desc(n)) %>%
  filter(n>0) %>%
  mutate(percent = round(n/sum(n),2)*100) %>%
  mutate(parents = "NA") %>%
  mutate(ids = paste(Conservation.Relevance)) %>%
  mutate(labels = paste0(Conservation.Relevance,"<br>",percent,"%")) %>%
  select(ids, labels, parents, n, percent)
lit.sun.4.expt <- lit.sun.4 %>% filter(!is.na(Expt.Factors)) %>%
  filter(Conservation.Relevance %in% lit.sun.4.cons$ids) %>%
  group_by(Conservation.Relevance,Expt.Factors) %>% 
  tally() %>% arrange(desc(n)) %>%
  filter(n>0) %>%
  mutate(percent = round(n/sum(n),2)*100) %>%
  mutate(parents = paste(Conservation.Relevance)) %>%
  mutate(ids = paste(Expt.Factors,parents,sep="_")) %>%
  mutate(labels = paste0(Expt.Factors,"<br>",percent,"%")) %>%
  select(ids, labels, parents, n, percent)
## Adding missing grouping variables: `Conservation.Relevance`
sunplot.cons2expt.data <- bind_rows(lit.sun.4.cons,
                                lit.sun.4.expt)

colors <- ifelse(grepl("biomarker", sunplot.cons2expt.data$ids),pal_npg()(1)[1],
                 ifelse(grepl("inter-population variation", sunplot.cons2expt.data$ids),pal_npg()(2)[2],
                 ifelse(grepl("intra-population variation", sunplot.cons2expt.data$ids),pal_npg()(3)[3],
                 ifelse(grepl("management decisions", sunplot.cons2expt.data$ids),pal_npg()(4)[4],
                 ifelse(grepl("reef festoration technology", sunplot.cons2expt.data$ids),pal_npg()(5)[5],
                 ifelse(grepl("heritability", sunplot.cons2expt.data$ids),pal_npg()(6)[6],
                 ifelse(grepl("restoration lines", sunplot.cons2expt.data$ids),pal_npg()(7)[7],
                 ifelse(grepl("cryptic species", sunplot.cons2expt.data$ids),pal_npg()(8)[8],
                 ifelse(grepl("methods development", sunplot.cons2expt.data$ids),pal_npg()(9)[9],
                 "grey")))))))))
sunplot.cons2expt.data$colors <- colors

Sunplot from conservation to experimental factors

sunplot.cons2expt <- plot_ly(sunplot.cons2expt.data, ids = ~ids, labels = ~labels, 
                 parents = ~parents, values= ~n, 
                 type = 'sunburst', branchvalues = 'total',
                 insidetextorientation="auto",
                 width = 500, height = 400,
                 marker = list(colors = sunplot.cons2expt.data$colors),
                 color = I('#FFFFFF'))
  
sunplot.cons2expt
# orca(sunplot.cons2expt, file = "sunplot_cons2expt.pdf")
# orca(sunplot.cons2expt, file = "sunplot_cons2expt.svg")